<template>
  <el-card>
    <el-table :data="attachList" style="width: 100%">
      <el-table-column prop="file_name" label="文件名" />
      <!-- <el-table-column prop="file_size" label="大小" :formatter="formatSize" /> -->
      <el-table-column prop="mime_type" label="类型" />
      <el-table-column prop="uploaded_at" label="上传时间" />
    </el-table>
  </el-card>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { getAttachmentListAPI, type AttachListItem } from '@/api/attachAPI'
// import axios from 'axios'
const attachList = ref<AttachListItem[]>([])

const props = defineProps({
  email_id: {
    type: Number,
    required: true,
  },
})

const email_id = props.email_id
const fetchAttachList = async () => {

  try {
    const res = await getAttachmentListAPI({
      email_id,
    })
    console.log(localStorage.getItem('token'));

    attachList.value = res.data

  } catch (error) {
    console.log('获取附件列表失败', error)
  }
}

onMounted(fetchAttachList)
</script>
